package com.top75;

/**
 * @Author: huangzhigao
 * @Date: 2023/5/10 21:18
 */
public class Code605 {
    public boolean canPlaceFlowers(int[] flowerbed, int n) {
        for (int i = 0, len = flowerbed.length; i < len && n > 0; ) {
            if (flowerbed[i] == 1) {
                i = i + 2;
            } else if (i == len - 1 || flowerbed[i + 1] == 0) {
                i = i + 2;
                n--;
            } else {
                i = i + 3;
            }
        }
        return n <= 0;
    }
}
